package person.bing.fbcloud.leetcode;

/**
 * 翻转二叉树
 * @author: mengfanbing
 * @date: 2020/9/16 9:13
 */
public class Q226 {
    public static void main(String[] args) {

    }
    public static TreeNode invertTree(TreeNode root) {
        util(root);
        return root;
    }
    public static void util(TreeNode node) {
        if (node == null){
            return;
        }
        TreeNode temp = node.left;
        node.left = node.right;
        node.right = temp;
        util(node.left);
        util(node.right);
    }



    public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
    }
}
